package com.dingwen.treasure.model.dto;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;

/**
 * 　LoginDto
 * 　@author dingwen
 * 　@date 2022/6/10
 */
@ApiModel(value = "LoginDto", description = "登录数据传输对象")
@Builder
@Getter
@Setter
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class LoginDto implements Serializable {

    /**
     * 账号
     */
    @ApiModelProperty(value = "账号")
    @NotBlank(message = "账号信息不能为空")
    @Size(max = 20, message = "账号长度不能超过20")
    private String account;

    /**
     * 密码
     */
    @ApiModelProperty(value = "密码")
    @NotBlank(message = "密码不能为空")
    @Size(min = 6, max = 20, message = "密码长度应该在6到20位之间")
    private String password;

    /**
     * 验证码
     */
    @ApiModelProperty(value = "验证码")
    @NotNull(message = "验证码不能为空")
    private Integer code;

    /**
     * 验证码 key (存储到redis)
     */
    @ApiModelProperty(value = "验证码key")
    @NotBlank(message = "验证码 key 不能为空")
    private String codeKey;


    /**
     * 重写get方法去除空格
     *
     * @return String
     */
    public String getAccount() {
        return account.trim();
    }

    /**
     * 重写get方法去除空格
     *
     * @return String
     */
    public String getPassword() {
        return password.trim();
    }
}
